﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sinacor.OMM.HealthMonitor.Entity.Common;

namespace Sinacor.OMM.HealthMonitor.Entity.HftProcessor
{
    [Serializable()]
    public class DataBase : IHealthDataReset
    {

        HealthEntityBase _healthEntityBase;
        public DataBase()
        {
            _healthEntityBase = new HealthEntityBase();
        }

        public DataBase(HealthEntityBase healthEntityBase)
        {
            _healthEntityBase = healthEntityBase;
        }

        //Limite
        private int _limitOperationAverageTime;// Tempo médio de operação em banco
        //Informacao
        private int _operationAverageTime;// Tempo médio de operação em banco
        private long _successfulTriesConnection;// Número de Re-Conexões com sucesso no BD
        private long _unsuccessfulTriesConnection; // Número de Tentativas Reconexão com Erro no BD

        public int LimitOperationAverageTime
        {
            get { return _limitOperationAverageTime; }
            set 
            { 
                _limitOperationAverageTime = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        public int OperationAverageTime
        {
            get { return _operationAverageTime; }
            set 
            { 
                _operationAverageTime = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        
        public long SuccessfulTriesConnection
        {
            get { return _successfulTriesConnection; }
            set 
            { 
                _successfulTriesConnection = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        
        public long UnsuccessfulTriesConnection
        {
            get { return _unsuccessfulTriesConnection; }
            set 
            { 
                _unsuccessfulTriesConnection = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        public void Reset()
        {
            LimitOperationAverageTime = 0;
            OperationAverageTime = 0;
            SuccessfulTriesConnection = 0;
            UnsuccessfulTriesConnection = 0;
        }
    }
}
